<?php

namespace plugin\admin\app\model\traits;

trait Listable
{
    public static $nameField = 'name';

    public static function list()
    {
        $data = self::all()->toArray();

        $newData = [];

        foreach ($data as $key=>$value) {
            $newData[] = ['name' => $value[self::$nameField], 'value' => $value['id']];
        }

        return $newData;
    }
}